package com.konne.nightmare.FastPublicOpinion.ui.personal.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.konne.nightmare.FastPublicOpinion.R;
import com.konne.nightmare.FastPublicOpinion.utils.DeviceUtil;

import java.util.List;

/**
 * @Author: chen
 * @UpdateDate: 1/23/22
 * @UpdateRemark:
 */
public class HelpAdapter extends BaseQuickAdapter<String, BaseViewHolder> {


    public HelpAdapter(int layoutResId, @Nullable List<String> data) {
        super(layoutResId, data);

    }

    @Override
    protected void convert(BaseViewHolder helper, String item) {

        TextView tvName = (TextView) helper.getView(R.id.tv_title);
        ImageView imgArrow = (ImageView) helper.getView(R.id.img_arrow);
        LinearLayout llContent = (LinearLayout) helper.getView(R.id.ll_content);
        RelativeLayout rlTitle = (RelativeLayout) helper.getView(R.id.rl_title);

        tvName.setText(item);

        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT, DeviceUtil.dip2px(mContext, 62));
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_content_list, null);
        view.setLayoutParams(lp);
        llContent.addView(view);

        rlTitle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               if (llContent.getVisibility() == View.VISIBLE){
                   llContent.setVisibility(View.GONE);
                   imgArrow.setImageResource(R.mipmap.icon_arrow_down);
               }else {
                   llContent.setVisibility(View.VISIBLE);
                   imgArrow.setImageResource(R.mipmap.icon_arrow_up);
               }
            }
        });
    }


}

